<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
<jsp:include page="inshead.jsp"></jsp:include>
<title>用户登录</title>
<!-- dwr -->
<script type='text/javascript' src='dwr/engine.js'></script>
<script type='text/javascript' src='dwr/util.js'></script>
<script type='text/javascript' src='dwr/interface/userAction.js'></script>
</head>
<body>



	<div align="center" style="border: black 1px;">
		<table style="border: solid 2px #646464;" cellspacing="14">
			<tr>
				<td>员工ID: <select id="loginin_id" /> 
				</td>
			<tr>
				<td>密&nbsp;&nbsp;码:&nbsp;<input type="password"
					id="loginin_password" />
				</td>
			</tr>

			<tr align="center">
				<td><input type="button" value="登陆" id="loginin_submit">
				</td>
			</tr>
		</table>

		<script type="text/javascript">
			userAction.getUsers(function(users) {
				console.log(users);
				for (var i = 0; i < users.length; i++) {
					$("#loginin_id").append(
							"<option value='"+users[i].account +"'>"
									+ users[i].account + "</option>");
				}
			});

			$("#loginin_submit").click(function() {
				var account = $("#loginin_id").val();
				var password = $("#loginin_password").val();

				if (password == "") {
					alert("请填写密码");
					return false;

				}
				userAction.validateUser(account,password, function(msg) {

					if (msg == null) {
						window.location.href='index.jsp';
					} else
						alert(msg);
					return false;
					//location.reload();
				});
				return false;
			});
		</script>

	</div>

</body>
</html>